package com.dkha.server.services.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dkha.common.modules.vo.camera.CameraInfoVO;
import com.dkha.server.modules.entities.ControlBayonetMid;
import com.dkha.server.mappers.ControlBayonetMidMapper;
import com.dkha.server.modules.entities.FaceCameraEntity;
import com.dkha.server.services.IControlBayonetMidService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 布控和摄像头中间表 服务实现类
 * </p>
 *
 * @author Spring
 * @since 2019-12-09
 */
@Service
public class ControlBayonetMidServiceImpl extends ServiceImpl<ControlBayonetMidMapper, ControlBayonetMid> implements IControlBayonetMidService {

    @Autowired
    ControlBayonetMidMapper controlBayonetMidMapper;

    @Override
    public Integer deletetaskandcarmerbytaskid(String taskID) {
        return controlBayonetMidMapper.deletetaskandcarmerbytaskid(taskID);
    }

    @Override
    public long selectexistByCarmeID(String idcamera) {
        long rs = controlBayonetMidMapper.selectexistByCarmeID(idcamera);
        return rs;
    }

    @Override
    public Integer updateCarmerValidaStateByTaskID(String taskID, String State, String UpdateBy) {
        return controlBayonetMidMapper.updateCarmerValidaStateByTaskID(taskID, State, UpdateBy);
    }

    @Override
    public List<FaceCameraEntity> selectFaceCameraBytaskID(String taskid) {
        return controlBayonetMidMapper.selectFaceCameraBytaskID(taskid);
    }

    @Override
    public List<FaceCameraEntity> selectFaceCameraBytask() {
        return controlBayonetMidMapper.selectFaceCameraBytask();
    }

    @Override
    public ControlBayonetMid selectFaceCameraByTime() {

        QueryWrapper<ControlBayonetMid> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_valid", "Y").orderByDesc("create_time").last("limit 1");
        return controlBayonetMidMapper.selectOne(queryWrapper);
    }

    @Override
    public int getControlByRegion(long regionId) {
        return controlBayonetMidMapper.getControlByRegion(regionId);
    }

    @Override
    public List<CameraInfoVO> selectFaceCameraBytaskInfo() {
        return controlBayonetMidMapper.selectFaceCameraBytaskInfo();
    }
}
